/*
 * testlog.cpp
 *
 *  Created on: Mar 9, 2011
 *      Author: tqlong
 */

#include "common/lognumber.h"
#include <armadillo>
#include <iostream>

namespace arma {
  template<> struct isnt_supported_elem_type< lognum > : public isnt_supported_elem_type_false {};
  template<> struct is_signed< lognum > { static const bool value = true; };
  template<> struct is_non_integral< lognum > { static const bool value = true; };
}

using namespace arma;

int main(int argc, char** argv)
{
  typedef Col<lognum> LogVec;
  typedef Mat<lognum> LogMat;
  LogVec a(2), b(2);
  LogMat A(2, 2);
  A.randn();

  std::cout << "a=\n" << a;
  a.zeros();
  b.ones();
  b*=-2;
  std::cout << "a=\n" << a;
  std::cout << "b=\n" << b;

  std::cout << "a+b=\n" << (a+b);
  std::cout << "a-b=\n" << (a-b);
  std::cout << "a%b=\n" << (a%b);
//  std::cout << "norm(a-b) = " << arma::norm(a-b,2) << "\n";

//  std::cout << "A = \n" << A;
//  LogVec x = solve(A,b);
//  std::cout << "solve Ax=b\nx=\n" << x;
  {
    mat A(2,2);
    A.randn();
    vec b(2);
    b.ones();
    std::cout << "A = \n" << A;
    vec x = solve(A,b);
    std::cout << "solve Ax=b\nx=\n" << x;
  }

  {
    lognum a(0), b(-1);
    std::cout << "COMPARISON TEST\n";
    std::cout << "a = " << a << " b = " << b << "\n";
    std::cout << "a>b=\n" << (a>b) << "\n";
    std::cout << "a<b=\n" << (a<b) << "\n";
    std::cout << "a<=b=\n" << (a<=b) << "\n";
    std::cout << "a>=b=\n" << (a>=b) << "\n";
    std::cout << "a==b=\n" << (a==b) << "\n";
    std::cout << "a!=b=\n" << (a!=b) << "\n";
  }
  //std::cout << "a/b=\n" << (a/b);
}
